<template>
	<view class="box-container">
		<view class="box">
			<view class="title">订单信息</view>
			<view class="list">
				<view class="item">
					<text class="label">订单编号：</text>
					<text class="value u-line-1">{{detail.num}}</text>
				</view>
				<view class="item">
					<text class="label">下单时间：</text>
					<text class="value u-line-1">{{detail.createTime}}</text>
				</view>
			</view>
		</view>
		<view class="box">
			<view class="title">{{detail.title}}</view>
			<view class="list">
				<view class="item">
					<text class="label">供应商单位：</text>
					<text class="value u-line-1">{{detail.supplierName}}</text>
				</view>
				<view class="item">
					<text class="label">要求供应时间：</text>
					<text class="value u-line-1">{{detail.supplyTime}}</text>
				</view>
				<view class="item">
					<span class="label">卸货位置：</span>
					<span class="value u-line-1">{{detail.locationName}}</span>
				</view>
				<view class="item">
					<span class="label">预计所需算量：</span>
					<span class="value u-line-1">{{detail.totalBudget}}t</span>
				</view>
			</view>
		</view>
		
		<view class="box">
			<view class="title">审批流程</view>
			<view class="timeline">
				<u-time-line>
					<u-time-line-item v-for="(item,index) in detail.approvalProcessVos" :key="index" nodeTop="4">
						<template v-slot:node>
							<view class="u-node" :style="item.status != 1 || index == 0 ? 'background: #19be6b;' : ''">
								<u-icon :name="index == 0 ? 'yewuliufaqibeifen2x' : 'shenpi'" custom-prefix="custom-icon" color="#fff" :size="22"></u-icon>
							</view>
						</template>
						<template v-slot:content>
							<view>
								<view class="name">
									<text>{{item.opretorName}}</text>
									<u-tag v-if="item.status == 0" :text="item.opretorRoleName" type="warning" shape="circle" size="mini" mode="dark"/>
									<u-tag v-else :text="item.status == 1 ? '审批中' : item.status == 3 ? '审批通过' : '审批驳回'" :type="item.status == 1 ? 'info' : item.status == 3 ? 'success' : 'error'" shape="circle" size="mini" mode="dark"/>
								</view>
								<view class="desc" v-if="item.opretorDesc">{{item.opretorDesc}}</view>
								<view class="time">{{item.opretorTime}}</view>
							</view>
						</template>
					</u-time-line-item>
					
				</u-time-line>
			</view>
		</view>
		<view class="op-box" v-if="detail.status > 1">
			<view class="btn-box">
				<view class="btn" @click="submit">人工匹配</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props:{
			orderId:{
				type: String,
				default: null
			},
			detail:{
				type:Object,
				default:()=>{}
			}
		},
		computed:{
			userinfo(){
				return JSON.parse(this.vuex_userInfo).user_info
			}
		},
		methods:{
			//拨打电话
			call(phone){
				uni.makePhoneCall({
				    phoneNumber: phone
				});
			},
			//驳回
			receivingReject(){
				uni.showModal({
					title: '提示',
					content: '是否驳回供应商发货请求，您需要线下联系供应商更改预计发货时间后再次提交发货请求！',
					success: (res) => {
						this.$u.api.receiptOrder({
							
						})
					}
				})
			},
			//确认订单
			receivingResovle(){
				uni.showModal({
					title: '提示',
					content: '是否确认供应商发货请求，供应商将在预计发货时间发货！',
					success: (res) => {
						if(res.confirm) {
							this.$emit('confirm')
						}
					}
				})
			},
			//手动匹配
			submit(){
				uni.navigateTo({
					url:`/pages/order/matching?id=${this.orderId}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box-container{
		padding-bottom: calc(90rpx + env(safe-area-inset-bottom)); ;
	}
	.box{
		background: #FFFFFF;
		border-radius: 10rpx;
		padding: 24rpx;
		margin-bottom: 20rpx;
		.title{
			font-size: 34rpx;
			font-weight: 800;
			border-bottom: 1px solid rgba(0, 0, 0, 0.1);
			padding-bottom: 24rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			&.no-border-bottom{
				border-bottom: none;
			}
		}
		.list{
			.item{
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;
				font-size: 28rpx;
				.label{
					color: #798188;
				}
				.value{
					color:#333;
					max-width: 400rpx;
				}
				.tel{
					color: #137AFF;
				}
			}
		}
		.info-list{
			display: flex;
			.item{
				width: 25%;
				display: flex;
				flex-direction: column;
				border-right: 1px solid rgba(212, 226, 237, 0.6);
				box-sizing: border-box;
				margin-right: 40rpx;
				&:last-child{
					border-right: none;
					margin-right: 0;
				}
				.v{
					font-size: 48rpx;
					font-weight: 500;
					color: #FF6600;
					.tips{
						font-size: 28rpx;
					}
				}
				.t{
					font-size: 24rpx;
					color: #888;
					margin-top: 6rpx;
				}
			}
		}
	}
	.timeline{
		padding: 30rpx 20rpx 0;
		.name{
			display: flex;
			align-items: center;
			margin-bottom: 10rpx;
			text{
				margin-right: 20rpx;
				font-size: 28rpx;
			}
		}
		.time{
			font-size: 24rpx;
			color: #798188;
		}
		.u-node {
			width: 34rpx;
			height: 34rpx;
			border-radius: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			background: #d0d0d0;
		}
		.desc{
			color: rgba(150,150,150,1);
			margin-bottom: 6rpx;
		}
	}
	.op-box{
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		background: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding:16rpx 30rpx 0;
		padding-bottom:calc(10rpx + env(safe-area-inset-bottom)); 
		box-shadow: 0px -4rpx 16rpx 0px rgba(0,0,0,0.15);
		z-index: 99;
		.btn-box{
			display: flex;
			align-items: center;
			width: 100%;
			.all{
				font-size: 28rpx;
				color: #28282C;
				text{
					color: #1378FF;
				}
			}
			.btn{
				height: 80rpx;
				background: linear-gradient(133deg, #12A6FF 0%, #1378FF 100%);
				border-radius: 44rpx;
				line-height: 80rpx;
				font-size: 34rpx;
				color: #fff;
				width: 100%;
				text-align: center;
			}
		}
	}
</style>
